package com.xinxin.leetcode.problem506;

import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

/**
 * @author ShiXinXin
 * @date 2020-01-10 9:25
 */
public class Solution {
    public String[] findRelativeRanks(int[] nums) {
        String[] res = new String[nums.length];
        Map<Integer, Integer> map = new HashMap<>(nums.length);
        for (int i = 0; i < nums.length; i++) {
            map.put(nums[i], i);
        }
        Arrays.sort(nums);
        for (int i = 0; i < nums.length; i++) {
            if (i == nums.length - 1) {
                res[map.get(nums[i])] = "Gold Medal";
            } else if (i == nums.length - 2) {
                res[map.get(nums[i])] = "Silver Medal";
            } else if (i == nums.length - 3) {
                res[map.get(nums[i])] = "Bronze Medal";
            } else {
                res[map.get(nums[i])] = String.valueOf(nums.length - i);
            }
        }
        return res;
    }

    public static void main(String[] args) {
        int[] arr = {10, 3, 8, 9, 4};
        System.out.println(Arrays.toString(new Solution().findRelativeRanks(arr)));
    }
}
